﻿<UserControl x:Class="BaMusaSoft.RPS.View.AllSchedulesView"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:p="clr-namespace:BaMusaSoft.RPS.View.Properties"
			 xmlns:vmp="clr-namespace:BaMusaSoft.RPS.ViewModel.Properties;assembly=ViewModel"
			 xmlns:wpfExtended="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
			 xmlns:localService="clr-namespace:BaMusaSoft.RPS.View.Services"
             x:Name="parentContainer"
             mc:Ignorable="d" 
			 d:DesignHeight="816" d:DesignWidth="1080"
			 FlowDirection="RightToLeft" Background="White" 
			 FontSize="{Binding Source={x:Static p:Settings.Default}, Path=FontSize}"
			 FontFamily="{Binding Source={x:Static p:Settings.Default}, Path=FontName}"
			 Loaded="ViewLoaded" Unloaded="ViewUnloaded">
	<UserControl.Resources>
		<localService:AllSchedulesTemplateSelector x:Key="SchedulesTemplateSelector"/>
		<GroupStyle x:Key="AllSchedulesCroupStyle">
			<GroupStyle.HeaderTemplate>
				<DataTemplate >
					<Border BorderBrush="Silver" BorderThickness="1" Margin="5" Background="Beige" >
						<TextBlock Text="{Binding Items[0].CustomerName}" FontSize="18" 
								   HorizontalAlignment="Center" Margin="3" Padding="5" />
					</Border>
				</DataTemplate>
			</GroupStyle.HeaderTemplate>
		</GroupStyle>
	</UserControl.Resources>

	<Grid >
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

        <ToolBar Margin="0,0,0,15" Grid.ColumnSpan="2">
            <Button Command="{Binding FindCommand}" Margin="5" ToolTip="بحث" Style="{StaticResource FindButtonStyle}"/>

            <Button Command="{Binding PrintCommand}" Margin="5" Style="{StaticResource PrintButtonStyle}"
                        ToolTip="طباعة"/>
            <Button Command="{Binding ShowGridColumnsVisibilty}" Margin="5" Style="{StaticResource ShowHideButtonStyle}"
                        ToolTip="إظهار - إخفاء الأعمدة"/>
            <Button Command="{Binding ElementName=parentContainer, Path = EditScheduleCommand}" Style="{StaticResource EditButtonStyle}"
                    ToolTip="تحرير"/>
        </ToolBar>

        <Border Grid.Row="1" Margin="3,3,51,5"   >
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
                
				<TextBlock Grid.Row="0" Margin="8,0" Text="{x:Static p:Resources.SearchFieldsLabel}"/>
				<TextBlock Grid.Column="0" Grid.Row="1" Text="{x:Static p:Resources.ContractPropertyNoLabel}" Margin="5" />
				<TextBlock Grid.Column="0" Grid.Row="2" Text="{x:Static p:Resources.SchdeduleNoLabel}" Margin="5" />
				<TextBlock Grid.Column="2" Grid.Row="1" Text="{x:Static p:Resources.FromDateLabel}" Margin="5" />
				<TextBlock Grid.Column="2" Grid.Row="2" Text="{x:Static p:Resources.ToDateLabel}" Margin="5" />
				<TextBox Grid.Column="1" Grid.Row="1" MinWidth="150" Text="{Binding Path=PropertyNo, UpdateSourceTrigger=PropertyChanged}" Margin="5,5,8,20.2" Width="175" Height="30" />
				<TextBox Grid.Column="1"  Grid.Row="2" MinWidth="150" Text="{Binding Path=ScheduleId, UpdateSourceTrigger=PropertyChanged}" Margin="5" Width="175" Height="30" />
				<wpfExtended:MaskedTextBox Grid.Column="3"  Grid.Row="1"  IncludeLiterals="False" Mask="##/ ## /####"  
									   Value="{Binding Path=FromDate, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DateConverter}}" Margin="5" HorizontalAlignment="Left" Width="175" Height="30"   />
				<wpfExtended:MaskedTextBox Grid.Column="3"  Grid.Row="2"  IncludeLiterals="False" Mask="##/ ## /####" 
									   Value="{Binding Path=ToDate, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DateConverter}}" Margin="5" Height="30" Width="175" HorizontalAlignment="Left" />
				<Rectangle Grid.ColumnSpan="3" Grid.Column="1" Fill="#FF3030E7" Height="1" Margin="0" Stroke="#FFBCBCF5" />
			</Grid>
		</Border>
        <DataGrid  Grid.Row="3" Grid.ColumnSpan="2" x:Name="schedulesDataGrid" AutoGenerateColumns="False" ItemsSource="{Binding AllSchedules}" Margin="0,5,5,5" 
                   CanUserAddRows="False" IsReadOnly="True" RowHeaderWidth="25">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="colScheduleId" Header="{x:Static p:Resources.SchdeduleNoLabel}" Binding="{Binding Path=ScheduleId}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowScheduleId, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}" />
                <DataGridTextColumn x:Name="colRegDate" Header="{x:Static p:Resources.ScheduleRegiLabel}" Binding="{Binding Path=RegistredAt, Converter={StaticResource MaskConverter}}" 
								    Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowRegistredAt, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colContractNo" Header="{x:Static p:Resources.ContractNoLabel}" Binding="{Binding Path=ContractNo}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowContractNo, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colCustomerId" Header="{x:Static p:Resources.CustomerNoLabel}" Binding="{Binding Path=CustomerId}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowCustomerId, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colCustomerName" Header="{x:Static p:Resources.CustomerNameLabel}" Binding="{Binding Path=CustomerName}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowCustomerName, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colPropertyNo" Header="{x:Static p:Resources.ContractPropertyNoLabel}" Binding="{Binding Path=PropertyNo}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowPropertyNo, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colPropertyDesc" Header="{x:Static p:Resources.ContractPropertyDescLabel}" Binding="{Binding Path=PropertyDescription}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowPropertyDescription, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colAmountDue" Header="{x:Static p:Resources.AmountDueLabel}" Binding="{Binding Path=AmountDue}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowAmoutDue, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colDateDue" Header="{x:Static p:Resources.DateDueLabel}" 
										Binding="{Binding Path = DateDue, Converter={StaticResource MaskConverter}}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowDateDue, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colAmountPaid" Header="{x:Static p:Resources.PaidLabel}" Binding="{Binding Path=AmountPaid}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowAmountPaid, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colBalance" Header="{x:Static p:Resources.BalanceLabel}" Binding="{Binding Path=Balance}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowBalance, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colSigner" Header="{x:Static p:Resources.SignerNameLabel}" Binding="{Binding Path=SignerName}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowSignerName, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colMobile" Header="{x:Static p:Resources.SignerMobileLabel}" Binding="{Binding Path=Mobile}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowSignerMobile, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridTextColumn x:Name="colPhone" Header="{x:Static p:Resources.SignerPhoneLabel}" Binding="{Binding Path=Phone}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowSignerPhone, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>
                <DataGridCheckBoxColumn x:Name="colPaid" Header="{x:Static p:Resources.HadPaidLabel}" Binding="{Binding Path=HadPaid}" Visibility="{Binding Source={x:Static vmp:Settings.Default}, Path= DataGrid_ShowHadPaid, Converter={StaticResource bool2VisibilityConverter}, Mode=TwoWay}"/>

            </DataGrid.Columns>
            <DataGrid.GroupStyle>
                <StaticResourceExtension ResourceKey ="AllSchedulesCroupStyle"/>
            </DataGrid.GroupStyle>
        </DataGrid>

    </Grid>
</UserControl>
